package com.mo2323.merchant.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.mo2323.common.util.AjaxObject;
import com.mo2323.service.merchant.IVoucherService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zj
 * @date 2019年1月26日14:57:10
 */
@Controller
@RequestMapping("/voucher")
public class VoucherController extends BaseController {
    @Reference
    private IVoucherService iVoucherService;

    @RequestMapping(value = "/issueVoucher", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public AjaxObject issueVoucher(@RequestParam Integer vid, @RequestParam Integer mid, @RequestParam Double voucherMoney, @RequestParam Double limitMoney) {
        try {
            iVoucherService.issueVoucher(vid, mid, voucherMoney, limitMoney);
            return AjaxObject.ok().data("发放优惠券成功！");
        } catch (Exception e) {
            logger.error("issueVoucher Exception：", e);
            return AjaxObject.error(e.getMessage());
        }
    }
}
